#!/bin/bash

# = calc_profit_all.sh
#
# Author::    takahiro
# Copyright:: takahiro
# License::   GPL
#

# == Version
#
# * 2014-02-10 1.00 (takahiro) 
#

# == Summary
# 
# This file is for
#

# == Interface
#
# * input
# **
# * output
# **
#

# == Example
#

# == Description
#
# This file is for
#


# function usage { 
#   echo "usage : $0 <HOGE>"
#   echo "ex ) $0 HOGE"
#   exit
# }
#

# while getopts "abd:h" options
# do
#   case $options in
#     a | b )
#     d     ) OPTDATA=${OPTARG} ;;
#     h | * ) usage ;;
#   esac
# done
# shift $( ( $OPTIND - 1  ) )
#


# if [ $# -ne 1 ]; then
#   usage
# fi
#
# HOGE=$1
#

RESULT_FILE=./profit.dat
echo -n > $RESULT_FILE

for signal_file in $(ls ./signal/*.dat)
do
  name=$(basename $signal_file .dat)
  for op in $(sed -e "s/ /,/g" ./operation.dat)
  do
    op=$(echo $op | sed -e "s/,/ /g" | sed -e "s/\n//g")
    oname=${name}_$(echo $op | sed -e "s/ /_/g")
    echo $oname >> $RESULT_FILE
    paste ./data/225.dat $signal_file | ./script/evaluate.py $op > ./evaluation/${oname}.dat
    cat ./evaluation/${oname}.dat | awk '{print $2}' | ./script/calc_profit.py >> $RESULT_FILE
    echo >> $RESULT_FILE
    echo [log] $oname done.
  done 
done

cat $RESULT_FILE

